import request from '@/utils/request.js'
const SIGHTS_PATH = '/user/sightsBooking'
const HOTEL_PATH = '/user/hotelBooking'

// 添加景点预约信息
export const addSightsBooking = (data) =>
  request.post(SIGHTS_PATH + '/addSightsBooking', data)

// 获取用户预约信息（判断是否过期）
export const getSightsBooking = ({ sightsId, userId }) =>
  request.get(SIGHTS_PATH + '/getSightsBooking', {
    params: { sightsId, userId }
  })

// 取消预约
export const cancelSightsBooking = ({ sightsId, userId, bookingId }) =>
  request.put(
    SIGHTS_PATH + `/cancelSightsBooking/${bookingId}/${sightsId}/${userId}`
  )

// 查询用户景点预约情况
export const getSightsBookingList = ({ page, pageSize, userId, status }) =>
  request.get(SIGHTS_PATH + '/getSightsBookingList', {
    params: {
      page,
      pageSize,
      userId,
      status
    }
  })

// 根据预约id查询预约信息
export const getSightsBookingById = (params) =>
  request.get(SIGHTS_PATH + `/getSightsBookingById`, { params })

// 使用
export const useSightsBooking = ({ id }) =>
  request.put(SIGHTS_PATH + `/useSightsBooking/${id}`)

// 生成二维码
export const getSightsQrCode = (params) =>
  request.get(SIGHTS_PATH + '/getQRCode', { params })

/****************************************************************************** */
// 新增酒店预约
export const addHotelBooking = (data) => request.post(HOTEL_PATH + '/add', data)

// 查询用户景点预约情况
export const getHotelBookingList = ({ page, pageSize, userId, status }) =>
  request.get(HOTEL_PATH + '/getHotelBookingList', {
    params: {
      page,
      pageSize,
      userId,
      status
    }
  })

// 使用预约id查询预约信息
export const getHotelBookingById = (params) =>
  request.get(HOTEL_PATH + '/getHotelBookingById', { params })

// 取消预约
export const cancelHotelBooking = ({
  hotelId,
  userId,
  bookingId,
  hotelSpecsId
}) =>
  request.put(
    HOTEL_PATH +
      `/cancelHotelBooking/${bookingId}/${hotelId}/${hotelSpecsId}/${userId}`
  )

// 使用
export const useHotelBooking = ({ id }) =>
  request.put(HOTEL_PATH + `/useHotelBooking/${id}`)

// 生成二维码
export const getHotelQrCode = (params) =>
  request.get(HOTEL_PATH + '/getQRCode', { params })
